package org.asiainfo.system.dubbo;

import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.asiainfo.common.core.utils.MapstructUtils;
import org.asiainfo.system.api.RemoteTenantService;
import org.asiainfo.system.api.domain.vo.RemoteTenantVo;
import org.asiainfo.system.domain.bo.SysTenantBo;
import org.asiainfo.system.domain.vo.SysTenantVo;
import org.asiainfo.system.service.SysTenantService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 租户服务
 *
 * @author dotor-ww
 */
@Service
@DubboService
@RequiredArgsConstructor
public class RemoteTenantServiceImpl implements RemoteTenantService {

    private final SysTenantService sysTenantService;

    /**
     * 查询租户信息
     *
     * @param tenantId 租户ID
     * @return 租户信息
     */
    @Override
    public RemoteTenantVo queryByTenantId(Long tenantId) {
        SysTenantVo sysTenantVo = sysTenantService.queryByTenantId(tenantId);
        return MapstructUtils.convert(sysTenantVo, RemoteTenantVo.class);
    }

    /**
     * 获取租户列表
     *
     * @return 租户信息
     */
    @Override
    public List<RemoteTenantVo> queryList() {
        List<SysTenantVo> sysTenantVos = sysTenantService.queryList(new SysTenantBo());
        return MapstructUtils.convert(sysTenantVos, RemoteTenantVo.class);
    }
}
